package com.apache.flow.core.manager;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.apache.core.orm.Page;
import com.apache.flow.core.dao.FlowSysDao;
import com.apache.flow.core.entity.FlowSys;
import com.apache.flow.vo.FlowSysQvo;

@Service
@Transactional
public class FlowSysManager {
	@Autowired
	private FlowSysDao flowSysDao;

	/**
	 * 
	 * @param id
	 * @return
	 * <p>@description 根据Id查询系统信息
	 * <p>@version 1.0
	 * <p>@author lvcai
	 * <p>@update 2013-7-29 下午04:55:48
	 */
	@Transactional(readOnly = true)
	public FlowSys getFlowSys(String id) {
		return flowSysDao.get(id);
	}

	/**
	 * 
	 * @param sysEname
	 * @return
	 * <p>@description 根据系统标识获取系统对象
	 * <p>@version 1.0
	 * <p>@author lvcai
	 * <p>@update 2013-7-29 下午04:56:10
	 */
	@Transactional(readOnly = true)
	public FlowSys getFlowSysBySysEname(String sysEname) {
		return flowSysDao.findUniqueBy("sysEname", sysEname);
	}

	/**
	 * 
	 * @param flowSys
	 * <p>@description 添加系统对象
	 * <p>@version 1.0
	 * <p>@author lvcai
	 * <p>@update 2013-7-29 下午04:56:36
	 */
	public void saveFlowSys(FlowSys flowSys) {
		flowSysDao.save(flowSys);
	}

	/**
	 * 
	 * @param flowSys
	 * <p>@description 添加系统对象
	 * <p>@version 1.0
	 * <p>@author lvcai
	 * <p>@update 2013-7-29 下午04:56:36
	 */
	public void saveSys(FlowSys flowSys) {
		flowSysDao.save(flowSys);
	}

	/**
	 * 获得所有权限系统注册信息
	 * @return List<Sys>
	 * @throws UctSysException 
	 */
	@Transactional(readOnly = true)
	public List<FlowSys> getAllFlowSys() throws Exception {
		return flowSysDao.getAllFlowSys();
	}

	/**
	 * 更新权限系统注册信息
	 * @param Sys
	 * @return Sys
	 */
	public FlowSys updateFlowSys(FlowSys flowSys) {
		flowSysDao.save(flowSys);
		return flowSys;
	}

	/**
	 * 删除权限系统注册信息
	 * @param id
	 */
	public void deleteSys(String id) {
		flowSysDao.delete(id);
	}

	/**
	 * 取到权限系统注册分页信息
	 * @param qvo
	 * @param pageNo
	 * @param pageSize
	 * @return Page<Sys>
	 * @throws UctSysException 
	 */
	@Transactional(readOnly = true)
	public Page<FlowSys> getSysListByQvo(FlowSysQvo qvo, int pageNo, int pageSize) throws Exception {
		return flowSysDao.getSysListByQvo(qvo, pageNo, pageSize);
	}

	/**
	 * 判断系统标识是否唯一
	 * @param propertyName
	 * @param value
	 * @return
	 */
	@Transactional(readOnly = true)
	public FlowSys getFlowSysListBypropertyName(String propertyName, String value) {
		return flowSysDao.findUniqueBy(propertyName, value);
	}
}
